package com.hb.core.pojo.project.portal.dto;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hb.core.pojo.Attachments;
import com.hb.core.pojo.project.portal.entity.PortalNotice;
import com.hb.core.pojo.project.portal.entity.PortalNoticeContent;
import com.hb.core.pojo.project.portal.entity.PortalNoticeFile;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;


/**
 * 门户公告DTO
 */
@Data
public class PortalNoticeDTO extends PortalNotice {

    /**
     * 公告内容
     */
    private String noviceContent;

    /**
     * 附件集合
     */
    List<PortalNoticeFile> portalNoticeFileList;


    /**
     * 发布开始时间
     */
    @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date publishStartDate;

    /**
     * 发布结束时间
     */
    @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date publishEndDate;

    private String deployTimeStr;

    /**
     * 参数验证方法
     * 该方法中验证的字段对应数据库中不能为空的字段
     *
     * @return
     */
    @Override
    public String paramsValid(String... fieldNames) {
        String projectName = getProjectName();
        if (StrUtil.isEmpty(projectName)) {
            return "项目名称不能为空";
        }
        String projectId = getProjectId();
        if (StrUtil.isEmpty(projectId)) {
            return "项目id不能为空";
        }
        String noticeTitle = getNoticeTitle();
        if (StrUtil.isEmpty(noticeTitle)) {
            return "公告标题不能为空";
        }
        String provinceName = getProvinceName();
        if (StrUtil.isEmpty(provinceName)) {
            return "省不能为空";
        }
        String cityName = getCityName();
        if (StrUtil.isEmpty(cityName)) {
            return "市不能为空";
        }
        Integer bidWay = getBidWay();
        if (null == bidWay) {
            return "招标方式不能为空";
        }
        String projectType = getProjectType();
        if (StrUtil.isEmpty(projectType)) {
            return "项目分类不能为空";
        }
        Integer noticeNature = getNoticeNature();
        if (null == noticeNature) {
            return "公告性质不能为空";
        }
        Integer noticeType = getNoticeType();
        if (null == noticeType) {
            return "公告类型不能为空";
        }
        String orgName = getOrgName();
        if (StrUtil.isEmpty(orgName)) {
            return "代理机构名称不能为空";
        }
        LocalDateTime deployTime = getDeployTime();
        if(null == deployTime){
            return "发布时间不能为空";
        }
        String receiveType = getReceiveType();
        if(StrUtil.isEmpty(receiveType)){
            return "系统标识不能为空";
        }
        String noviceContent = getNoviceContent();
        if(StrUtil.isEmpty(noviceContent)){
            return "公告内容不能为空";
        }
        return null;
    }
}
